package Jun13.doc;

import Jun13.index.GetIndex;
import Jun13.pojo.User;
import Jun13.utils.ESUtils;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.elasticsearch.action.get.GetRequest;
import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.common.xcontent.XContentType;

import java.io.IOException;

public class GetDoc {

    public static void main(String[] args) throws IOException {
        RestHighLevelClient rest = ESUtils.getRest();//获取ES对象
        GetRequest index = new GetRequest().index("user").id("1002");//获取对象，指定在哪个索引下寻找哪个对象
        GetResponse result = rest.get(index, RequestOptions.DEFAULT);//发起获取请求
        System.out.println(result.getSource());//打印结果
        rest.close();//关闭
    }
}
